import React, { Component } from 'react';

// 导入action
import  { get_user_list } from "@/actions/user"
import { Table } from 'antd';

class User extends Component {
    columns = [
        { title: "用户ID", dataIndex: "uid", key: "uid", width: 200 },
        { title: "用户名", dataIndex: "username", key: "username", width: 200 },
        { title: "角色名", dataIndex: "rolename", key:"rolename",width:200 }
    ]
    page_change = (newpage)=>{
        this.$store.dispatch({ type:"USER_SET_PAGE",payload:newpage})
        get_user_list();
    }
    render() {
        let { user: { total, size, page, userlist } } = this.$store.getState()
        return (
            <Table pagination={{ current: page, pageSize: size, total: total, onChange:this.page_change}} dataSource={userlist} columns={ this.columns } />
        );
    }
    componentDidMount(){
        get_user_list();
        this.$store.subscribe(()=>{
            this.setState({})
        })
    }

}

export default User;
